<script  setup >
import { ref } from "vue";
import LiaoTian from "../components/LiaoTian";

import { formatCurrentTime } from "../tool/index.js";

const list = ref([
  {
    left: false,
    message: "你好呀~11",
    date: formatCurrentTime(),
  },
]);

const send = (message, scrollToBottom) => {
  list.value.push({
    left: false,
    message,
    date: formatCurrentTime(),
  });

  scrollToBottom && scrollToBottom();

  setTimeout(() => {
    // 后端返回的数据格式
    list.value.push({
      left: true,
      message: `<img src="https://image2.cqcb.com/d/file/yuedu/yeyu/2021-07-05/e04b4e681628a1dfddd44c7130248cd1.jpg">`,
      date: formatCurrentTime(),
    });

    scrollToBottom && scrollToBottom();
  }, 2000);
};
</script>


<template>
  <LiaoTian @send="send" :list="list"></LiaoTian>
</template>

<style  lang="scss"  scoped>
</style>